using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace TVDesigner.Generator
{
    public class FileGenerator
    {
        public static void CreateFile(FileGeneratorParameters param)
        {
            Validate(param);

            string file = string.Concat(param.Location, "\\", param.Name, ".", param.Extension);

            TextWriter sw = new StreamWriter(file);
            sw.Write(param.Data);            
            sw.Flush();
            sw.Close();
        }

        public static void CreateFile(byte[] file)
        {
        }

        private static void Validate(FileGeneratorParameters param)
        {
            if (param == null)
                throw new FileGeneratorException("FileGeneratorParameters == null");

            if (param.Location == null || param.Location.Length == 0)
                throw new FileGeneratorException("Invalid Location");

            //if (param.Name == null || param.Name.Length == 0)
            //    throw new FileGeneratorException("Invalid Name");

            if (param.Location == null || param.Location.Length == 0)
                throw new FileGeneratorException("Invalid Data");
        }
    }
}
